home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4754 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1018 b   |  48 lines

  1. Path: enterprise.turningpoint.com!loki
  2. From: sathan@cybercom.net (Stephen Athanas)
  3. Newsgroups: comp.lang.c++
  4. Subject: Possible VC 4.0 bug?
  5. Date: 31 Jan 1996 22:39:52 GMT
  6. Organization: Turning Point Software
  7. Message-ID: <4eor3o$d06@enterprise.turningpoint.com>
  8. NNTP-Posting-Host: steve.turningpoint.com
  9. X-Newsreader: News Xpress Version 1.0 Beta #4
  10.  
  11. When I compile and run the following code under MSVC 4.0, I get an access 
  12. violation on the delete:
  13.  
  14. -------------------------------------------------------------------------
  15.  
  16. #include <stdio.h>
  17.  
  18. class foo
  19.     {
  20.     public :
  21.         virtual ~foo( );
  22.     };
  23.  
  24. foo::~foo( )
  25.     {
  26.     printf( "In foo::~foo.\n" );
  27.     }
  28.  
  29. int main( )
  30.     {
  31.     foo* p = new foo[ 0 ];
  32.  
  33.     delete [] p;
  34.  
  35.     return 0;
  36.     }
  37.  
  38. --------------------------------------------------------------------------
  39.  
  40. Everything works fine, and the destructor is never called, if the destructor 
  41. is not virtual.
  42.  
  43. Is this a problem with VC, or with my understanding of how a new of size zero 
  44. should work? Thanks.
  45.  
  46. Steve Athanas
  47. sathan@cybercom.net
  48.